package cn.iocoder.yudao.module.ao.dal.mysql.department;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ao.dal.dataobject.department.DepartmentDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.ao.controller.admin.department.vo.*;

/**
 * 院系信息 Mapper
 *
 * @author 智教云枢
 */
@Mapper
public interface DepartmentMapper extends BaseMapperX<DepartmentDO> {

    default PageResult<DepartmentDO> selectPage(DepartmentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DepartmentDO>()
                .likeIfPresent(DepartmentDO::getDeptName, reqVO.getDeptName())
                .eqIfPresent(DepartmentDO::getDeptCode, reqVO.getDeptCode())
                .eqIfPresent(DepartmentDO::getDeptHeadId, reqVO.getDeptHeadId())
                .eqIfPresent(DepartmentDO::getContactPhone, reqVO.getContactPhone())
                .eqIfPresent(DepartmentDO::getOfficeLocation, reqVO.getOfficeLocation())
                .eqIfPresent(DepartmentDO::getDescription, reqVO.getDescription())
                .eqIfPresent(DepartmentDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(DepartmentDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(DepartmentDO::getDeptId));
    }

    default List<DepartmentDO> selectListByStatus(Integer status) {
        return selectList(new LambdaQueryWrapperX<DepartmentDO>()
                .eqIfPresent(DepartmentDO::getStatus, status)
                .orderByAsc(DepartmentDO::getDeptId));
    }

}